;var babiApp = window.babiApp || {};
babiApp = function(){
	return {
		init:function(){
			var _this = this;
			_this.incSlideFun();
			_this.xsjqFun();
		},
		incSlideFun:function(){
			var scaleW=window.innerWidth/320;
            var scaleH=window.innerHeight/480;
            var resizes = document.querySelectorAll('.resize');
              for (var j=0; j<resizes.length; j++) {
               resizes[j].style.width=parseInt(resizes[j].style.width)*scaleW+'px';
               resizes[j].style.height=parseInt(resizes[j].style.height)*scaleH+'px';
               resizes[j].style.top=parseInt(resizes[j].style.top)*scaleH+'px';
               resizes[j].style.left=parseInt(resizes[j].style.left)*scaleW+'px'; 
              };
              var mySwiper = new Swiper ('.swiper-container', {
               direction : 'vertical',
               pagination: '.swiper-pagination',
              //virtualTranslate : true,
               mousewheelControl : true,
               onInit: function(swiper){
               swiperAnimateCache(swiper);
               swiperAnimate(swiper);
                  },
               onSlideChangeEnd: function(swiper){
                swiperAnimate(swiper);
                },
                onTransitionEnd: function(swiper){
                swiperAnimate(swiper);
                },
                
                
                watchSlidesProgress: true,

                  onProgress: function(swiper){
                    for (var i = 0; i < swiper.slides.length; i++){
                      var slide = swiper.slides[i];
                      var progress = slide.progress;
                      var translate = progress*swiper.height/4;  
                      scale = 1 - Math.min(Math.abs(progress * 0.5), 1);
                      var opacity = 1 - Math.min(Math.abs(progress/2),0.5);
                      slide.style.opacity = opacity;
                      es = slide.style;
                      es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = 'translate3d(0,'+translate+'px,-'+translate+'px) scaleY(' + scale + ')';

                    }
                  },
                
                   onSetTransition: function(swiper, speed) {
                    for (var i = 0; i < swiper.slides.length; i++){
                      es = swiper.slides[i].style;
                      es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = speed + 'ms';

                    }
                  },
                
                
                
                   })
		},
		xsjqFun:function(){
			$('#xsjqBtn').on('click',function(){
				window.location.href = "http://duoduojf.com/meitai/babiApp/html/xsjq.html"
			});
			$('.zdppjs_main').on('click','span',function(){
				var $this = $(this),
					num = $this.attr('data-num'),
					imgHtml = '';
				$('.bpic_main').show().html('<img src="../img/ppjs_'+ num +'.jpg" />');
			});
			$('.bpic_main').on('click','img',function(){
				$('.bpic_main').hide().html('');
			});
		},
	}
	
};
(function(){
    var supportOrientation = (typeof window.orientation === 'number' &&
            typeof window.onorientationchange === 'object');

    var init = function(){
        var htmlNode = document.body.parentNode,
            orientation;
        var updateOrientation = function(){
            if(supportOrientation){
                orientation = window.orientation;
                switch(orientation){
                    case 90:
                    case -90:
                        orientation = 'landscape';
                        break;
                    default:
                        orientation = 'portrait';
                        break;
                }
            }else{
                orientation = (window.innerWidth > window.innerHeight) ? 'landscape' : 'portrait';
            }
            htmlNode.setAttribute('class',orientation);
            if(orientation == 'portrait'){
            	alert('该网页在竖屏模式无法正常展示，请切换到横屏再浏览！');
            }
        };

        if(supportOrientation){
            window.addEventListener('orientationchange',updateOrientation,false);
        }else{
            //监听resize事件
            window.addEventListener('resize',updateOrientation,false);
        }

        updateOrientation();
    };

    window.addEventListener('DOMContentLoaded',init,false);
})();

$(document).ready(function() {
    jQuery.fn.anim_progressbar = function(aOptions) {
        // def values
        var iCms = 1000;
        var iMms = 60 * iCms;
        var iHms = 3600 * iCms;
        var iDms = 24 * 3600 * iCms;

        // def options
        var aDefOpts = {
            start: new Date(), // now
            finish: new Date().setTime(new Date().getTime() + 60 * iCms), // now + 60 sec
            interval: 100
        }
        var aOpts = jQuery.extend(aDefOpts, aOptions);
        var vPb = this;

        // each progress bar
        return this.each(
            function() {
                var iDuration = aOpts.finish - aOpts.start;

                // calling original progressbar

                // looping process
                var vInterval = setInterval(
                    function() {
                        var iLeftMs = aOpts.finish - new Date(); // left time in MS
                        var iElapsedMs = new Date() - aOpts.start, // elapsed time in MS
                            iDays = parseInt(iLeftMs / iDms), // elapsed days
                            iHours = parseInt((iLeftMs - (iDays * iDms)) / iHms), // elapsed hours
                            iMin = parseInt((iLeftMs - (iDays * iDms) - (iHours * iHms)) / iMms), // elapsed minutes
                            iSec = parseInt((iLeftMs - (iDays * iDms) - (iMin * iMms) - (iHours * iHms)) / iCms), // elapsed seconds
                            iPerc = (iElapsedMs > 0) ? iElapsedMs / iDuration * 100 : 0; // percentages

                        // display current positions and progress
                        $(vPb).children('.jindu').html(iPerc.toFixed(0)+'%');

                        // in case of Finish
                        if (iPerc >= 100) {
                            clearInterval(vInterval);
                            $('#loding').hide();
                        }
                    }, aOpts.interval
                );
            }
        );
    }

    // default mode
    var iNow = new Date().setTime(new Date().getTime() + 5 * 1000); // now plus 5 secs
    var iEnd = new Date().setTime(new Date().getTime() + 15 * 1000); // now plus 15 secs
    $('#loding').anim_progressbar({
        start: iNow,
        finish: iEnd,
        interval: 100
    });
});